 // 模拟前端数据访问测试
const mockApiResponse = {
    "success": true,
    "data": {
      "correlation_analysis": {
        "temp_max": {
          "pearson_correlation": 0.818,
          "impact_level": "强相关",
          "description": "最高温度与负荷呈正相关，温度升高时负荷增加"
        },
        "temp_min": {
          "pearson_correlation": 0.888,
          "impact_level": "强相关",
          "description": "最低温度与负荷呈正相关，但影响程度略低于最高温度"
        },
        "precip": {
          "pearson_correlation": -0.147,
          "impact_level": "弱相关",
          "description": "降水量对负荷影响较小，雨天可能略微降低负荷"
        },
        "humidity": {
          "pearson_correlation": -0.786,
          "impact_level": "强相关",
          "description": "湿度与负荷呈负相关，高湿度时负荷可能降低"
        }
      },
      "time_series": {
        "dates": ["06-20", "06-21", "06-22", "06-23", "06-24"],
        "temp_max": [28.19, 29.67, 29.78, 31.32, 31.31],
        "temp_min": [22.48, 20.48, 24.30, 25.13, 25.10],
        "precip": [0.0, 0.0, 0.0, 0.0, 0.0],
        "humidity": [66.79, 64.75, 66.66, 67.39, 61.06],
        "load": [44657.62, 46223.62, 45653.93, 46907.51, 47049.71]
      },
      "summary": {
        "total_days": 30,
        "analysis_period": {
          "start_date": "2025-06-20",
          "end_date": "2025-07-19"
        }
      }
    },
    "message": "气象负荷相关性分析完成"
  };
  
  // 模拟前端组件的数据处理
  function testFrontendDataAccess() {
    console.log('测试前端数据访问...');
    
    // 模拟前端接收数据
    const response = mockApiResponse;
    
    if (response.success) {
      const correlationData = response.data;
      console.log('✅ 数据接收成功');
      console.log('correlationData:', correlationData);
      
      // 检查时间序列数据
      const timeSeriesData = correlationData.time_series;
      if (timeSeriesData && timeSeriesData.dates) {
        console.log('✅ 时间序列数据存在');
        console.log('日期数量:', timeSeriesData.dates.length);
        console.log('负荷数据数量:', timeSeriesData.load.length);
        console.log('最高温度数据数量:', timeSeriesData.temp_max.length);
        console.log('最低温度数据数量:', timeSeriesData.temp_min.length);
        console.log('降水量数据数量:', timeSeriesData.precip.length);
        console.log('湿度数据数量:', timeSeriesData.humidity.length);
        
        // 检查数据是否完整
        const allDataComplete = timeSeriesData.dates.length > 0 &&
                               timeSeriesData.load.length > 0 &&
                               timeSeriesData.temp_max.length > 0 &&
                               timeSeriesData.temp_min.length > 0 &&
                               timeSeriesData.precip.length > 0 &&
                               timeSeriesData.humidity.length > 0;
        
        if (allDataComplete) {
          console.log('✅ 所有数据完整，图表应该能正常渲染');
        } else {
          console.log('❌ 数据不完整');
        }
      } else {
        console.log('❌ 时间序列数据不存在');
      }
    } else {
      console.log('❌ API响应失败');
    }
  }
  
  // 运行测试
  testFrontendDataAccess();